﻿//*** Guidance generated code ***//
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using $safeprojectname$.Storage;

namespace $safeprojectname$
{
    /// <summary>
    ///     Extensions available on every place of the framework.
    /// </summary>
    public static partial class Ext
    {
        #region Cache
        static readonly CacheStorage CacheStorage = new CacheStorage();

        /// <summary>
        ///     Provides the common interface for Cache usage,
        ///     published via ICacheStorage. Base inner implementation relies on the System.Web caching
        /// </summary>
        /// <param name = "dao">any dao object which needs the cache mechanism</param>
        /// <returns></returns>
        public static ICacheStorage Cache(this IDao dao)
        {
            return CacheStorage;
        }
        #endregion Cache

        #region Session
        /// <summary>
        ///     Returns ISessionStorage object wrapper.
        /// </summary>
        /// <param name = "context"></param>
        /// <returns></returns>
        public static ISessionStorage Session(this ControllerContext context)
        {
            return SessionManager.GetSessionStorage(context.Is() ? context.HttpContext : null);
        }

        /// <summary>
        ///     Returns ISessionStorage object wrapper.
        /// </summary>
        /// <param name = "context"></param>
        /// <returns></returns>
        public static ISessionStorage Session(this HttpContext context)
        {
            return SessionManager.GetSessionStorage(context);
        }
        #endregion Session
    }
}